Skip to content

docs(python): document environment= kwarg on arcjet() / arcjet_sync()#829

Open
estellajaysong wants to merge 4 commits into
mainfrom
estella/update-py-sdk-env-kwarg
Open

docs(python): document environment= kwarg on arcjet() / arcjet_sync()#829
estellajaysong wants to merge 4 commits into
mainfrom
estella/update-py-sdk-env-kwarg

Conversation

@estellajaysong
Copy link
Copy Markdown
Contributor

@estellajaysong estellajaysong commented May 21, 2026

Summary

Documents the environment= kwarg shipped in arcjet/arcjet-py#127. Users on pydantic-settings (or any config library that doesn't propagate .env into os.environ) can now pass dev/prod mode explicitly instead of relying on ARCJET_ENV being readable via os.getenv.

  • src/content/docs/reference/python.mdx — Adds environment to the Configuration optional-fields bullet list with "development" / "production" stated inline, plus a new #### Pydantic-settings users subsection with a runnable BaseSettings example. arcjet_sync() is called out for Flask/Django users.
  • src/content/docs/environment.mdx — Adds a one-line pointer under ### ARCJET_ENV, NODE_ENV so customers who land on the concept page searching ARCJET_ENV get routed to the kwarg. Mechanism explanation lives on the reference page only.

Why

pydantic-settings — the de-facto FastAPI config pattern — loads .env into a typed BaseSettings object by design and does not write values back to os.environ. The Python SDK reads ARCJET_ENV via os.getenv, so without an explicit channel between the two, the SDK defaults to production mode for users on this pattern. The new environment= kwarg is that bridge, and the docs need to point users to it where they'll look for the symptom.

Test plan

Open the Vercel preview link from the PR's checks (sidebar → "Visit Preview"), then walk through:

  • Anchor exists. Open /reference/python on the preview. Scroll down to (or Cmd+F) the Pydantic-settings users heading. Click the heading and confirm the URL becomes …/reference/python#pydantic-settings-users.
  • Bullet → subsection. On the same page, in the Configuration section, find the environment bullet (between proxies and the FastAPI/Flask code tabs). Click the Pydantic-settings users link in that bullet. Confirm it jumps to the subsection on the same page.
  • Bullet → ARCJET_ENV. In the same environment bullet, click the ARCJET_ENV link. Confirm it navigates to /environment#arcjet-env and scrolls to the ARCJET_ENV, NODE_ENV heading.
  • Concept page → reference. Open /environment directly on the preview. Find the ARCJET_ENV, NODE_ENV section. Click the Python SDK reference link in the "Python SDK users: …" sentence. Confirm it lands on /reference/python#pydantic-settings-users.
  • Visual scan. On /reference/python, read the Configuration section end-to-end (from ### Configuration through #### Load balancers & proxies) and confirm the new bullet and subsection sit naturally in the flow with no rendering glitches.

🤖 Generated with Claude Code

…ync()`

Covers the pydantic-settings escape hatch added in arcjet/arcjet-py#127:
pass `environment=settings.ARCJET_ENV` so dev-mode gating (loopback IP
fallback, `X-Arcjet-Ip` override, dev-mode timeout) works when the
config library doesn't propagate `.env` into `os.environ`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 21, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
arcjet-docs Ready Ready Preview, Comment May 21, 2026 8:11pm

Request Review

…ctive audit

- Lead the pydantic-settings subsection with the directive (use the kwarg)
  and explain the library design difference rather than framing it as
  silent SDK failure.
- State accepted values (`"development"` / `"production"`) inline on the
  optional-fields bullet so readers don't have to dig into the subsection
  to learn what strings the kwarg accepts.
- Trim the trailing migration note; keep the `arcjet_sync()` mention.
- Mirror the tone change in `environment.mdx`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
- Drop the dev-mode behavior enumeration from the pydantic-settings
  subsection; the cross-link to `environment.mdx#arcjet-env` carries
  that detail.
- Compact the pointer paragraph in `environment.mdx` to a single line
  so the page stays a concept reference rather than absorbing
  Python-SDK-specific mechanism notes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@arcjet-review arcjet-review Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arcjet Review — 🟢 Low Risk

Decision: Approved

Rationale: Documentation-only change that adds guidance for Python SDK users on the existing environment= kwarg, particularly when using pydantic-settings which doesn't propagate .env into os.environ. No code changes, no security implications, no escalation triggers fired. Example code is a typical pydantic-settings pattern with no hardcoded secrets (key is sourced from settings).

Summary of Changes

Adds documentation in environment.mdx and reference/python.mdx explaining that Python SDK users on pydantic-settings (or similar config libraries that don't write back to os.environ) should pass ARCJET_ENV via the environment= kwarg on arcjet() / arcjet_sync(). Includes a new 'Pydantic-settings users' subsection with a code example and cross-links between the two docs pages.

Notes

Docs-only PR, well under the 1000-line threshold. Security-review skill checklist applied: no secrets, no auth/crypto/injection surface touched; example code uses settings-sourced key rather than a hardcoded value.

Review: 983e0c7c | Powered by Arcjet Review

Comment thread src/content/docs/reference/python.mdx
Comment thread src/content/docs/reference/python.mdx
…s example

The example is illustrating the exact case where customers hit the
issue — local dev. Defaulting to "development" matches that intent
and makes the wiring testable without setting the value in `.env`.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@estellajaysong
Copy link
Copy Markdown
Contributor Author

To be merged post Python SDK release for the relevant feature: arcjet/arcjet-py#127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant